package edu.scau.divineplace.controller;

import cn.hutool.core.util.PageUtil;
import edu.scau.divineplace.config.global.log.WebLog;
import edu.scau.divineplace.entity.query.CommentForumQuery;
import edu.scau.divineplace.entity.query.PageQuery;
import edu.scau.divineplace.entity.vo.commentforum.CommentForumVO;
import edu.scau.divineplace.service.CommentForumService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: x1aolone
 * @Date: 2020/12/11 15:47
 */
@Slf4j
@RestController
@CrossOrigin
@Api("CommentForum控制器")
@WebLog("CommentForum控制器")
@RequestMapping("/commentForum")
public class CommentForumController {
    @Autowired
    private CommentForumService commentForumService;

    @ApiOperation("通过内容id、内容类型、用户id获取内容的楼层评论，支持分页")
    @GetMapping("/list/{contentId}")
    public List<CommentForumVO> list(@PathVariable Long contentId, Integer commentTargetType, Long userId, PageQuery pageQuery){
        return commentForumService.list(contentId, commentTargetType, userId, pageQuery);
    }

    @ApiOperation("新增回复")
    @PostMapping("")
    public void add(@Validated CommentForumQuery query){
        commentForumService.add(query);
    }


}
